﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace canyinguanlixitong
{
    public partial class POS结账 : Form
    {
        public POS结账()
        {
            InitializeComponent();
        }
        public string ggz;
        public int spID;
        string str = "Data Source=.;Initial Catalog=Supermarket management system;Integrated Security=True";
        private void POS结账_Load(object sender, EventArgs e)
        {
            je();
        }
        public void je()
        {
            SqlConnection con = new SqlConnection(str);
            con.Open();
            string a = @"select spJia from dbo.commodity where spID='" + spID + "'";
            SqlCommand com = new SqlCommand(a, con);
            SqlDataReader reader = com.ExecuteReader();
            if (reader.Read())
            {
                this.label10.Text = reader["spJia"].ToString();
                this.label4.Text = reader["spJia"].ToString();
            }
        }

        private void btn_Click(object sender, EventArgs e)
        {
            double i = Convert.ToDouble(this.textBox3.Text);
            double z = Convert.ToDouble(this.label10.Text);
            double po = i - z;
            this.textBox1.Text = po.ToString();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (this.textBox3.Text.Equals(this.label10.Text))
            {
                MessageBox.Show("支付成功", "提示");
                this.Close();
                this.Close();
            }
            else
            {
                MessageBox.Show("支付金额与消费金额不符");
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
